﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Reflection;

namespace Test.Expressions
{

	/// <summary>
	/// A custom expression node used to represent a SQL SELECT expression
	/// </summary>
	public class SelectExpression : SubqueryExpression
	{		
		
		public SelectExpression(
			string alias,
			Type type,
			IEnumerable<ColumnExpression> columns,
			Expression from,
			IEnumerable<Expression> appended = null,
			Expression where = null,						
			bool isDistinct = false,
			Expression skip = null,
			Expression take = null)
			: base(nodeType: DbExpressionType.Select, 
			type: type,
			columns: columns,
			from: from, 
			appended: appended,
			where: where, 
			take: take, skip: skip, isDistinct: isDistinct) {			
			this.alias = alias;
		}
				
		/// <summary>
		/// Alias on this means the alias to this entire selection expression, not its "from",
		/// which is also consistent with the other DbExpression types.
		/// </summary>
		public string Alias {
			get {
				return this.alias;
			}			
		}
		string alias;
		public override string ToString() {
			return base.ToString() + " \"" + this.Alias + "\"";
		}
		
	}

}
